//
//  UiButton+Extention.swift
//  SinaWb
//
//  Created by Jiang on 16/5/8.
//  Copyright © 2016年 Jiang. All rights reserved.
//

import UIKit
extension UIButton{
    convenience init(imageName: String , backimageName :String){
            self.init()
        if UIImage(named: imageName) != nil{
            
            setImage(UIImage(named: imageName), forState: UIControlState.Normal)
            setImage(UIImage(named: imageName  + "_highlighted"), forState: UIControlState.Highlighted)
        
        }
        if UIImage(named: backimageName) != nil {
            
            setBackgroundImage(UIImage(named: backimageName), forState: UIControlState.Normal)
            setBackgroundImage(UIImage(named: backimageName  + "_highlighted"), forState: UIControlState.Highlighted)
        }
        
        sizeToFit()
        
    }
    convenience init(title : String,imageName : String, backgroundImageName: String){
        self.init()
        titleEdgeInsets  = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0)
        imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5)
        titleLabel?.font = UIFont.systemFontOfSize(13)
        setTitle(title, forState: .Normal)
        setTitleColor(UIColor.lightGrayColor(), forState: .Normal)
        setImage(UIImage(named:imageName), forState: .Normal)
        setBackgroundImage(UIImage(named:"timeline_card_bottom_background"), forState: .Normal)
        setBackgroundImage(UIImage(named:backgroundImageName + "_highlighted"), forState: .Highlighted)
        
    }

    
}